import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';

export default function getSortInitData(callback) {

    const {orgVal, rosterRefVal} = this.state;

    if (!orgVal.refpk || !rosterRefVal.refpk) return;
    let postData = {
        pk_org: orgVal.refpk,
        pk_rpt_def: rosterRefVal.refpk
    };

    return proFetch({
        url: '/nccloud/hrhi/listrep/ListRptSortAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                this.setState({
                    allSortField: res.data.allSortingFields,
                    sort_field: res.data.defaultSortingFields
                }, () => {
                    callback && callback();
                })
            }
        });
}
